<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
	<head>
		<style>
		    BODY, TD, TH { 
		      font-family: verdana, arial, helvetica, sans-serif;
		      font-size: 12px;
		    }
		
			a.nameLink {
				color: #000099;
				font-weight: bold;
			}
			a.nameLink:hover {
				color: #990000;
				font-weight: bold;
			}
			input.large {
				width: 300px;
			}
			table.searchResults {
				border-collapse: collapse;
			}
			table.searchResults tr.th {
				background-color: #EBEBEB;
			}
			table.searchResults tr.homonym {
				background-color: #ebf0ff;
			}
			table.searchResults td.homonym {
				background-color: #ebf0ff;
			}
			table.searchResults th {
				padding: 5px 10px 5px 10px;
				text-decoration: underline;
				border: 2px solid #EBEBEB;
			}
			table.searchResults td {
				padding: 5px 10px 5px 10px;
				border: 2px solid #EBEBEB;
			}
			table td.red {
				background-color: #ef9d9d;
			}
			table td.yellow {
				background-color: #edef9d;
			}
			table td.green {
				background-color: #a7ef9d;
			}
			table.searchResults td.center {
				text-align: center;
			}
		</style>
	</head>
	<body>
		<p>
			<s:form action="search" validate="false">
				<s:text name="label.search"/>: <input type="text" name="q" class="large" value="<s:property value="q"/>"/> <input type="submit" value="<s:text name="button.search"/>"/>	
			</s:form>
		</p>
		
		<s:if test="genus != null">
			<h1><i><s:property value="genus.canonical"/></i> 
				 <s:if test="genus.authorship!=null">
					<s:property value="genus.authorship"/>
				</s:if>						
			</h1>
    
		    
		    <p>
			    <table class="searchResults">
			    	<tr class="th">
			    		<th><s:text name="datasources"/></td>
			    	</tr>
					<s:iterator value="genus.genusUsages">
						<tr>
							<td>
								<s:if test="remoteId != null">
									<a href="%{remoteId.remoteId}"><s:property value="agiDatasource.name"/></a><br/>
								</s:if>
								<s:else>
									<s:property value="agiDatasource.name"/><br/>
								</s:else>
							</td>
						</tr>
					</s:iterator>
				</table>
			</p>
		
			<table class="searchResults">
				<s:iterator value="groupedGenusRelationships.relationships">
					<tr class="th"><th colspan="2"><s:property value="key.type"/></th></tr>
						<s:iterator value="value">
							<tr>
								<td>
									<s:if test="${param.id == toGenus.id}">
										<s:url id="detailUrl" action="detail">
											<s:param name="id" value="fromGenus.id"/>
										</s:url>
										<s:a href="%{detailUrl}">
											<i><s:property value="fromGenus.canonical"/></i> <s:property value="fromGenus.authorship"/>
										</s:a>
									</s:if>
									<s:if test="${param.id == fromGenus.id}">
										<s:url id="detailUrl" action="detail">
											<s:param name="id" value="toGenus.id"/>
										</s:url>
										<s:a href="%{detailUrl}">
											<i><s:property value="toGenus.canonical"/></i> <s:property value="toGenus.authorship"/>
										</s:a>
									</s:if>
									<s:if test="%{agiDatasource != null}">
										<td>
											<s:property value="agiDatasource.name"/>
										</td>
									</s:if>
									<s:elseif test="%{user != null}">
										<td>
											<s:property value="user.username"/>
										</td>
									</s:elseif>
									<s:elseif test="%{algorithm != null}">
										<td>
											<s:property value="algorithm.name"/> (<s:text name="version"/> <s:property value="algorithm.version"/>)
										</td>
									</s:elseif>
									<s:else>
										<td/>
									</s:else>		
							</tr>
							<tr><td colspan="2">&nbsp;</td></tr>
						</s:iterator>
				</s:iterator>
			</table>
		</s:if>
	</body>
</html>
